#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
void practice_9_43();
void practice_9_44();
void replace_with(string &s,const string &prefix,const string &suffix);
void practice_9_45();
void replace(string &s,const string &prefix,const string &suffix);
void practice_9_46();
void practice_9_47();
void practice_9_49();
void practice_9_50();
int main()
{
	//practice_9_43();
	//practice_9_44();
	//practice_9_45();
	//practice_9_46();
	//practice_9_47();
	//practice_9_49();
	practice_9_50();
	return 0;
}
void practice_9_43()
{
	string s("hahahzyl ahduwzyl afhwzylwqf");
	string oldVal("zyl");
	string newVal("zyl111ok");
	for(auto it=s.begin();it!=s.end();){
		string temp{it,it+oldVal.size()};
		if(temp==oldVal){
			it=s.erase(it,it+oldVal.size());
			for(auto end=newVal.end()-1;end-newVal.begin()>=0;--end)
				it=s.insert(it,*end);
			it+=newVal.size();
		}
		else
			++it;
	}
	cout<<s<<endl;
}
void practice_9_44()
{
	string s("hahahzyl ahduwzyl afhwzylwqf");
	string oldVal("zyl");
	string newVal("zyl111ok");
	using length=decltype(s.size());
	for(length i;i<s.size();){
		length to_size=i+oldVal.size();
		if(to_size<s.size()){
			string s1=s.substr(i,oldVal.size());
			if(s1==oldVal){
				s.replace(i,oldVal.size(),newVal);
				i+=newVal.size();
			}
			else
				++i;
		}
		else
			break;
	}
	cout<<s<<endl;
}
void replace_with(string &s,const string &prefix,const string &suffix)
{
	auto it=s.begin();
	for(auto end=prefix.end()-1;end-prefix.begin()>=0;--end){
		it=s.insert(it,*end);
	}
	s.append(suffix);

}
void practice_9_45()
{
	string s("Tommy");
	replace_with(s,"Mr.","III");
	cout<<s<<endl;
}
void replace(string &s,const string &prefix,const string &suffix)
{
	s.insert(0,prefix);
	s.insert(s.size(),suffix);
}
void practice_9_46()
{
	string s("Tommy");
	replace(s,"Mr.","III");
	cout<<s<<endl;
}
void practice_9_47()
{
	string object("ab2c3d7R4E6");
	string numbers("0123456789");
	string alphabets("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLNMOPQRSTUVWXYZ");
	cout<<object.find_first_of(numbers)<<endl;
	cout<<object.find_first_not_of(alphabets)<<endl;
}
void practice_9_49()
{
	int max_length=0;
	string word,maxstring;
	ifstream input("words.txt");
	while(input>>word){
		if(word.find_first_of("dfpg")==string::npos){
			if(word.size()>=max_length){
				max_length=word.size();
				maxstring=word;
			}
		}
	}
	cout<<maxstring<<endl;	
}
void practice_9_50()
{
	int sum=0;
	vector<string> v{"12","13","35","123","57"};
	for(auto s:v){
		int a=stoi(s);
		sum+=a;
	}
	cout<<sum<<endl;
}